<?php

if (!defined("_GNUBOARD_")) exit; // 개별 페이지 접근 불가 

$default_charset = '';
if (preg_match("/^utf/i", $g4['charset']))
    $default_charset = "default charset=utf8;";

$sql = "create table if not exists {$mw_coupon['info_table']} (
cp_id int not null auto_increment,
cp_subject varchar(255) not null,
cp_count int not null,
cp_flag varchar(1) not null,
cp_type char(1) not null,
cp_sdate date not null,
cp_edate date not null,
cp_price int not null,
cp_multi varchar(1) not null,
cp_regday int not null,
cp_regday_type varchar(1) not null,
cp_datetime datetime not null,
primary key (cp_id)) ".$default_charset;
sql_query($sql);

$sql = "create table if not exists {$mw_coupon['list_table']} (
cp_id int not null,
cp_rel_table varchar(20) not null,
cp_rel_id int not null,
cp_coupon varchar(19) not null,
cp_use varchar(1) not null,
cp_ip varchar(20) not null,
mb_id varchar(20) not null,
cp_use_datetime datetime not null,
index (cp_id),
index (cp_coupon)) ".$default_charset;
sql_query($sql);

sql_query("alter table {$mw_coupon['list_table']} add mb_id_only varchar(20) not null after mb_id", false);
sql_query("alter table {$mw_coupon['info_table']} add cp_mb_id text not null after cp_count", false);

sql_query("alter table {$mw_coupon['list_table']} add cp_rel_table varchar(20) not null after cp_id", false);
sql_query("alter table {$mw_coupon['list_table']} add cp_rel_id int not null after cp_rel_table", false);

sql_query("alter table {$mw_coupon['info_table']} add cp_regday int not null after cp_multi", false);
sql_query("alter table {$mw_coupon['info_table']} add cp_regday_type varchar(1) not null after cp_regday", false);

